<?php
/**
 * 经营类目管理
*
* @author karl <karl.tang@aiyuangong.com>
* @link http://www.aiyuangong.com
*/
namespace app\admin\controller\store;

use app\admin\Controller;
use think\Db;

class StoreBindClass extends Controller
{
    use \app\admin\traits\controller\Controller;

    protected static $blacklist = [
        'clear'
    ];
    
    public function index(){
        // 状态列表
        $stateList = [
            0 => '审核中',
            1 => '已审核',
            2 => '平台自营'
        ];
        $this->view->assign('state_list', $stateList);
        $store_id = $this->request->param('store_id/d',0);
        $where = [];
        if($store_id){
            $where['store_id'] = $store_id;
        }
        if ($this::$isdelete !== false) {
            $where['sbc.isdelete'] = $this::$isdelete;
        }
        $count = Db::name('store_bind_class')->alias('sbc')->where($where)->count();
        $list = Db::name('store_bind_class')->alias('sbc')->join('store s','sbc.store_id=s.id','LEFT')->field('sbc.*,s.name as store_name,s.seller_name')->where($where)->paginate();
        $this->view->assign('list',$list);
        $this->view->assign('count',$count);
        return $this->view->fetch();
    }

    /**
     * 绑定分类审核
     */
    public function auditOK()
    {
        return $this->updateField("state", 1, "审核成功", '', '', 'store_bind_class');
    }
}